<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <link th:href="@{/static/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
</head>
<body>
<div class="container main">


    <div class="mt-4 mb-4">
        <ul class="nav nav-tabs">
<!--            <li class="nav-item">-->
<!--                <a class="nav-link" th:href="@{/index}">用户管理</a>-->
<!--            </li>-->
            <li class="nav-item">
                <a class="nav-link" th:href="@{/product/list}">商品管理</a>
            </li>
            <li class="nav-item" th:if="${session.loginUser != null && session.loginUser.role == 0}">
                <a class="nav-link active" aria-current="page" th:href="@{/cart/list}">购物车</a>
            </li>
        </ul>
    </div>


<!--    <article class="mb-4">-->
<!--        <form class="form-inline" action="/cart/list" id="form1" method="post">-->
<!--            <div class="row">-->
<!--                <div class="col-md-3">-->
<!--                    <input type="text" class="form-control" id="i" placeholder="请输入ID" th:value="${id}" name="id">-->
<!--                </div>-->
<!--                <div class="col-md-3">-->
<!--                    <input type="text" class="form-control" id="name" placeholder="请输入商品名称"-->
<!--                           th:value="${name}" name="name">-->
<!--                </div>-->
<!--                <div class="col-md-3">-->
<!--                    <button type="submit" class="btn btn-primary">查询</button>-->

<!--                    <a class="btn btn-primary btn-xs" th:href="@{/cart/create}">新增</a>-->
<!--                </div>-->
<!--            </div>-->
<!--        </form>-->
<!--    </article>-->
    <table class="table table-bordered table-hover table-striped" th:id="table">
        <tr>
            <td>ID</td>
            <td>名称</td>
            <td>价格</td>
            <td>数量</td>
            <td>操作</td>
        </tr>
        <tr th:each="item : ${list}" th:id="${item.id}">
            <td th:text="${item.id}"></td>
            <td th:text="${item.product.name}"></td>
            <td th:text="${item.product.price}"></td>
            <td th:text="${item.quantity}"></td>
            <td>
                <div class="action">
                    <a class="btn btn-primary btn-sm" th:href="@{/cart/update(id=${item.id})}">编辑</a>
                    <a class="btn btn-danger btn-sm" th:href="@{/cart/remove(id=${item.id})}">删除</a>
                </div>
            </td>
        </tr>
    </table>

    <script th:src="@{/static/bootstrap/js/bootstrap.bundle.min.js}"></script>
</div>

</body>
</html>